<%@page pageEncoding = "utf-8" contentType = "text/html;charset=utf-8"%>

<%@taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions"%>

<script type="text/javascript">
window.onload = function () {
  startdate  = new Epoch('epoch_popup','popup',document.getElementById('startdate'));
  enddate  = new Epoch('epoch_popup','popup',document.getElementById('enddate'));
};
</script>

<h2>
  <c:if test = "${action == 'processEditTaskForm'}">Редактирование задачи</c:if>
  <c:if test = "${action == 'processAddTaskForm'}">Добавление задачи</c:if>
</h2>

<div class = "messages"><jsp:include page = "/messages.jsp"/></div>

<form action = "leadexecutorui" method = "post" name = "taskForm">
   <table class = "form">   
      <tr>
         
         <td class = "label"><fmt:message key = "task.executor"/><span class="star">*</span></td>
         <td>
            <select id="employeesList" name="employee_id">              
              <option value="0"><fmt:message key = "task.executor.option"/></option>
              <c:forEach var = "employee" items = "${employeesList}">
                <option value="${employee.id}" ${employee.id == taskBean.employeeId ? "selected" : ""}>
                   <c:out value="${employee.lastName} ${employee.firstName}"/>
                </option>
              </c:forEach>
            </select>
            <span class="error"><c:out value="${error.executor}"/></span>
         </td>
      </tr>                  
      
      <tr>
         <td class = "label">Название<span class="star">*</span></td>
         <td>
            <input name = "name" type="text" value='<c:out value = "${taskBean.name}"/>' maxlength="100">
            <span class="error"><c:out value="${error.name}"/></span>
         </td>
      </tr>
               
      <tr>
         <td class = "label"><fmt:message key = "task.text"/><span class="star">*</span></td>
         <td>
            <textarea name = "text" rows="10" cols="50"><c:out value = "${taskBean.text}"/></textarea>
            <span class="error"><c:out value="${error.taskText}"/></span>
         </td>
      </tr>
      
      <tr>
         <td class = "label">Дата начала<span class="star">*</span></td>
         <td>
           <input class="date" id="startdate" type="text" name="startdate" value='<fmt:formatDate value="${taskBean.startDate}" pattern="dd.MM.yyyy"/>'/>
           <span class="error"><c:out value="${error.startDate}"/></span>
         </td>
      </tr>     
      
      <tr>
         <td class = "label">Завершить к<span class="star">*</span></td>
         <td>
           <input class="date" id="enddate" type="text" name="enddate" value='<fmt:formatDate value="${taskBean.approxEndDate}" pattern="dd.MM.yyyy"/>'/>
           <span class="error"><c:out value="${error.endDate}"/></span>
         </td>
      </tr>      
      
      <tr>
         <td class = "label"><fmt:message key = "task.priority"/><span class="star">*</span></td>
         <td>
            <ul class="simple"> 
            <c:forEach var = "priority" items = "${priorityList}">
               <li>
                  <input type="radio" name="priority" value="${priority.id}" ${priority.id == taskBean.priority ? "checked" : ""}/>
                  ${priority.value}
               </li>            
            </c:forEach>
            <span class="error"><c:out value="${error.priority}"/></span>
            </ul>
         </td>
      </tr>
      
      <tr>
         <td class = "label"><input type="checkbox" name="donotify"/></td>
         <td>
            Отправить уведомление исполнителю
         </td>
      </tr>
</table>

<input name = "_action" type = "hidden" value="${action}">   
<input name = "task_id" type = "hidden" value="${taskBean.id}">   
<input name = "request_id" type = "hidden" value="${taskBean.requestId}">   

<p>Обязательные для заполнения поля отмечены <span class="star">*</span></p>

<input type="submit" value="Сохранить"> 
или
<a href = "leadexecutorui?_action=requestDetails&request_id=${taskBean.requestId}">
Отмена
</a>
</form>